﻿using Nectar.DAL.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace P2PWeb.Models
{
    public class Pager<Model>
    {
        public int CurrentPageIndex { get; set; }

        public static int PageSize
        {
            get
            {
                return 20;
            }
        }

        public int TotialItemsCount { get; set; }

        public int TotialPaqgerCount
        {
            get
            {
                return TotialItemsCount % PageSize == 0 ? TotialItemsCount / PageSize : TotialItemsCount / PageSize + 1;
            }
        }
        public List<Model> Items { get; set; }

        public QueryParameter[] GetQueryParameters()
        {
            return new QueryParameter[] 
            {
                new QueryParameter(){
                     Name="Skip",Value=(PageSize*(CurrentPageIndex-1)),
                },
                new QueryParameter(){
                     Name="Limit",Value=(PageSize),
                },
            };
        }
    }
}